<!DOCTYPE html>
<html lang="cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    function GetRan(n, m) {
        return Math.floor(Math.random() * (m - n + 1)) + 1;
    }
    let ran = GetRan(1, 10);
    console.log("随机数是：" + ran);
    let count = 0;

    if (count < 3) {

        for (i = 0; i < 3; i++) {
            let iptNum = +prompt("请输入一个数字：");
            if (iptNum > ran) {
                alert("你输入的数字大了");
            } else if (iptNum < ran) {
                alert("你输入的数字小了");
            } else {
                alert("恭喜你猜对了");
                break;
            }
            count++;
        }
    }
    if (count == 3) {
        alert("你已经猜了3次了，游戏结束");
    }



    // document.write("0-10之间：" + ran);
</script>